<template>
  <div class="my-tag">
    <input class="input"
     type="text" 
     v-focus
     @blur="isShow = false"
     @keydown.enter="change"
     v-if="isShow"
     v-model="inputTag"
     placeholder="输入标签" />
     <!-- isShow 影响上面的  v-if="isShow" 双击让上面显示-->
    <div class="text" @dblclick="changeTag" v-else>{{value}}</div>
  </div>
</template>

<script>
export default {
  name: "VueDemoMyTag",
  props: {
    value: {
      type:String,
      required:true
    }
  },
  data() {
    return {
      isShow: false,
      inputTag: ''
    };
  },

 

  methods: {
    changeTag() {
     this.isShow =true
     this.inputTag =this.value

    },
    change() {
      this.$emit('input',this.inputTag)
      this.isShow =false
    }
  },
};
</script>

<style lang="less" scoped>
.my-tag {
  cursor: pointer;
  .input {
    appearance: none;
    outline: none;
    border: 1px solid #ccc;
    width: 100px;
    height: 40px;
    box-sizing: border-box;
    padding: 10px;
    color: #666;
    &::placeholder {
      color: #666;
    }
  }
}
</style>